package org.mozhu.mboot.core.web;

import com.google.common.collect.Lists;
import org.springframework.data.domain.Page;

import java.util.List;

public class Select2Response<T> {

	public final static int DEFAULT_SELECT_PAGE_SIZE = 10;

	private Long totalCount;

	private List<T> items = Lists.newArrayList();

	public Long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Long totalCount) {
		this.totalCount = totalCount;
	}

	public List<T> getItems() {
		return items;
	}

	public void setItems(List<T> items) {
		this.items = items;
	}

	public Select2Response() {
	}

	public Select2Response(Page<T> page) {
		this.setTotalCount(page.getTotalElements());
		this.setItems(page.getContent());
	}

	public Select2Response(List<T> items, Long totalCount) {
		this.items = items;
		this.totalCount = totalCount;
	}
}
